package com.wteam.dragon.model.service.impl;

import cn.hutool.core.lang.Dict;
import com.wteam.dragon.system.basebean.bean.ResultMessage;
import com.wteam.dragon.system.util.FileUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author 陈晓辉
 * @Date 2020/4/10 11:35
 * 上传文件的类
 */
@Service
public class FileServiceImpl {
    /**
     * 上传文件方法
     * @return
     */
    public ResultMessage uploadFile(MultipartFile file, String  typePath, FileUtil.FileType type) {
        FileUtil.FilePath filePath = FileUtil.uploadFile(file, typePath, type);
        Dict dict = Dict.create().set("uploadFilePath", filePath.getVisitPath());
        ResultMessage resultMessage = new ResultMessage();
        resultMessage.setStatus(200);
        resultMessage.setMessage("上传文件成功");
        resultMessage.setResultParam(dict);
        return resultMessage;
    }

}
